package thread;

import java.util.function.Consumer;

/**
 * @author ：xxx
 * @description：TODO
 * @date ：2024/04/28 15:47
 */
public class ThreadDemo {

    private static final long timeInterval = 3000L;


    public static void main(String[] args) {
        // run in a second
//        final long timeInterval = 1000;

        Thread thread = new Thread(myRunnable());
        thread.start();
    }

    // 线程等待
//    public static void main(String[] args) {
//        Thread thread = new Thread(ThreadDemo::myRunnable);
//
//        thread.start();
//    }




    public static Runnable myRunnable(){
        return ()->{
            while (true) {
                System.out.println("Hello !!");
                try {
                    Thread.sleep(timeInterval);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        };
    }
}
